package com.loadmore.common.util;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;

public class PermissionUtils {
    public static boolean checkPermissions(Context context,String[] permissions) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            for (int i = 0; i < permissions.length; i++) {
                if (context.checkSelfPermission(permissions[i]) == PackageManager.PERMISSION_DENIED) {
                    return false;
                }
            }
            return true;
        }else {
            return true;
        }
    }
    @TargetApi(Build.VERSION_CODES.M)
    public static void requestPermissions(Activity context, String[] permissions, int requestCode) {
        context.requestPermissions(permissions, requestCode);
    }
}
